﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace PollSystemService
{
    [ServiceContract]
    public interface IPollService
    {

        [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json)]
        IEnumerable<PollDTO> GetPolls();

        [OperationContract]
        [WebInvoke(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        IEnumerable<AnswerDTO> GetVotes(Vote vote);

    }

    [DataContract]
    public class PollDTO
    {
        string question;
        IEnumerable<string> answers;
        [DataMember]
        public string pQuestion
        {
            get { return question; }
            set { question = value; }
        }

        [DataMember]
        public IEnumerable<string> pAnswers 
        {
            get { return answers; }
            set { answers = value; }
        }
    }

[DataContract]
    public class AnswerDTO
    {
        string text;
        int votes;

        [DataMember]
        public string Text
        {
            get { return text; }
            set { text = value; }
        }

        [DataMember]
        public int Votes
        {
            get { return votes; }
            set { votes = value; }
        }
    }

[DataContract]
public class Vote
{
    string question;
    String answer;
    [DataMember]
    public string Question
    {
        get { return question; }
        set { question = value; }
    }

    [DataMember]
    public String Answer
    {
        get { return answer; }
        set { answer = value; }
    }
}
}
